[vars]
filesize=11202492
sha512=06371d47b02caec83c7662f6bb4a827eafb7f3309f6cda959a0f49b647df031166a6e7c5d530b57b580104289ee260aa96f3f43cbfffcef816cea776b0d5aed0
desc='media player with support for most audio/video formats'

[mirrors]
http://www.mplayerhq.hu/MPlayer/releases/MPlayer-1.1.1.tar.xz

[deps]
libtheora
libxxf86dga
libxv
libmad
libao
zlib
sdl
x11-font-dejavu
libxvmc
alsa-lib
mesalib
libpng

[deps.host]
yasm

[build]
patch -p1 < "$K"/mplayer-x11-libs.patch

[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--target="$A"-linux"
isx86=0
disrt=0
case "$A" in
  i[3-6]86) isx86=1 ;;
  x86_64) isx86=1 ;;
  x32) isx86=1 ;;
  arm) disrt=1 ;;
  mips) disrt=1 ;;
esac
test "$isx86"x = 0x && xconfflags="$xconfflags \
  --disable-mmx --disable-mmxext --disable-sse --disable-sse2 --disable-ssse3"
test "$disrt"x = 1x && \
  xconfflags="$xconfflags --disable-runtime-cpudetection"

# figure out arm cpu optimizations...
[ "$A" = arm ] && {
	gccv=$($CC -v 2>&1|grep "^Configured with: ")
	for flag in --with-arch --with-fpu ; do
		for arg in $gccv ; do
			if printf "%s" "$arg" | grep "^$flag=" >/dev/null ; then
			if [ "$flag" = "--with-arch" ] ; then
				case $arg in
					--with-arch=armv[67]*)
						xconfflags="$xconfflags --enable-armv6t2" ;;
					--with-arch=armv5*)
						xconfflags="$xconfflags --enable-armv5te" ;;
				esac
			elif [ "$flag" = "--with-fpu" ] ; then
				case $arg in
					--with-fpu=vfpv3*)
						xconfflags="$xconfflags --enable-vfpv3" ;;
					--with-fpu=vfp*)
						xconfflags="$xconfflags --enable-armvfp" ;;
					--with-fpu=neon*)
						xconfflags="$xconfflags --enable-neon" ;;
				esac
			fi
			fi
		done
	done
}

printf "#!/bin/sh\necho -lfreetype -I$butch_root_dir$butch_prefix/include/freetype2\n" > freetype-config
chmod +x freetype-config
printf "#!/bin/sh\necho -lSDL -I$butch_root_dir$butch_prefix/include/SDL\n" > sdl-config
chmod +x sdl-config
export PATH="$PWD:$PATH"

CPPFLAGS="-D_GNU_SOURCE" CFLAGS="$optcflags" CXXFLAGS="$optcflags" \
LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
./configure --prefix="$butch_prefix" \
	--disable-gui \
	--disable-gif \
	--disable-arts \
	--enable-x11 \
	--enable-runtime-cpudetection \
	--disable-nas \
	--enable-gl \
	--disable-musepack \
	--disable-mp3lib \
	--disable-ossaudio \
	--disable-pulse \
	--disable-openal \
	--disable-mp3lib \
	--disable-esd \
	--disable-mga \
	--disable-lirc \
	--enable-xvmc \
	--disable-nemesi $xconfflags
echo "INSTALLSTRIP =" >> config.mak
sed -i 's@strip@$(STRIP)@' Makefile
make V=1 -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install STRIP=true
